package com.whjfxx.terminal.utils;

import com.alibaba.fastjson.JSONObject;
import com.whjfxx.terminal.biz.param.SearchParam;
import com.whjfxx.terminal.biz.param.UserPageParam;

import java.util.function.Consumer;

/**
 * Created by b.c on 2022/5/20 8:55
 */
public final class QueryUtil {

    /**
     * 查询
     * @param searchParam
     * @param consumer
     * @param <D>
     */
    public static final <D> void search(SearchParam<D> searchParam,Class<D> clazz, Consumer<D> consumer) {
        D pageParam = searchParam.getSearchParams();
        if (null == pageParam) {
            return;
        }
        if (pageParam instanceof String) {
            D param = JSONObject.parseObject((String)pageParam, clazz);
            consumer.accept(param);
            return;
        }
        consumer.accept(pageParam);
    }
}
